<?php

class CHCTooltip extends AbstractHCObject
{
    
    /**
     *  The background color or gradient for the tooltip. 
     *  
     *  Defaults to "rgba(255, 255, 255, .85)".
     *  
     * @param String $psColor
     */
    public function setBackgroundColor($psColor, $pnOpacity=75)
    {
        if (CSDebug::assertHex($psColor)) return false;
        if (CSDebug::assertInteger($pnOpacity, true)) return false;
        
        $xColor01 = substr($psColor, 1, 2);
        $xColor02 = substr($psColor, 3, 2);
        $xColor03 = substr($psColor, 5, 2);
        
        // Translation from hex to dec
        $sRgba = 'rgba('.hexdec($xColor01).', '.hexdec($xColor02).', '.hexdec($xColor03).', '.($pnOpacity / 100).')';
        
        $this->setParam('backgroundColor', $sRgba);
    }
    
    
    /**
     *  The color of the tooltip border. 
     *  When "auto", the border takes the color of the corresponding series or point. 
     *  
     *  Defaults to "auto".
     *  
     * @param String $psColor
     */
    public function setBorderColor($psColor='auto')
    {
        // default
        if ($psColor == 'auto') return true;
        
        if (CSDebug::assertHex($psColor)) return false;
        
        $this->setParam('borderColor', $psColor);
    }
    
    
    /**
     *  The radius of the rounded border corners. 
     *  
     *  Defaults to 5.
     *  
     * @param Integer $pnInteger
     */
    public function setBorderRadius($pnInteger=5)
    {
        if (CSDebug::assertInteger($pnInteger)) return false;
        
        $this->setParam('borderRadius', $pnInteger);
    }
    
    
   /**
    * The pixel width of the tooltip border. 
    *  
    * Defaults to 2.
    *  
    * @param Integer $pnInteger
    */
    public function setBorderWidth($pnInteger=2)
    {
        if (CSDebug::assertInteger($pnInteger)) return false;
        
        $this->setParam('borderWidth', $pnInteger);
    }
    
    
    /**
     * Enable or disable the tooltip. 
     * 
     * Defaults to true.
     *  
     * @param Boolean $pbBoolean
     */
    public function setEnabled($pbBoolean=true)
    {
        if (CSDebug::assertBoolean($pbBoolean)) return false;
        
        $this->setParam('enabled', $pbBoolean);
    }
    
    
    /**
     * Callback function to format the HTML of the tooltip. 
     * 
     * Available data are:
     * 
     * this.x: 		The x value.
     * this.y: 		The y value.
     * this.series: The series object.  	# The series name is available through this.series.name.
     * this.point: 	The point object. 		# The point name, if defined, is available through this.point.name.
     * 
     * Default value:
     * formatter: function() 
     * {
     * 		return  ''+ (this.point ? this.point.name : this.series.name) +'
     * 				'+
     * 				'X value: '+ this.x +'
     * 				'+
     * 				'Y value: '+ this.y;
     * }
     * 
     * @param String <JS> $psString
     */
    public function setFormatter($psString)
    {
        if (CSDebug::assertString($psString)) return false;
        
        $this->setParam('formatter', $this->tokenize($psString));
    }
    
    
   /**
    *  Whether to apply a drop shadow to the tooltip. 
    *  
    *  Defaults to true.
    *  
    * @param Boolean $pbBoolean
    */
    public function setShadow($pbBoolean=true)
    {
        if (CSDebug::assertBoolean($pbBoolean)) return false;
        
        $this->setParam('shadow', $pbBoolean);
    }
    
    
    /**
     * CSS styles for the tooltip. 
     * The tooltip can also be styled through the CSS class .highcharts-tooltip. 
     * 
     * Default value: 
     * 
     * @param Array $pasArray
     */
    public function setStyle($pasArray)
    {
      if (CSDebug::assertArray($pasArray)) return false;
      
      $this->setParam('style', $pasArray);
    }
}

?>